package com.lh.project.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.beans.SimpleBeanInfo;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 秒杀优惠券表，与优惠券是一对一关系
 * @TableName seckill_voucher
 */
@TableName(value ="seckill_voucher")
@Data
public class SeckillVoucher implements Serializable {
    /**
     * 关联的优惠券的id
     */
    @TableId(value = "voucher_id", type = IdType.ASSIGN_ID)
    private Long voucherId;

    /**
     * 库存
     */
    @TableField(value = "stock")
    private Integer stock;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 生效时间
     */
    @TableField(value = "begin_time")
    private Date beginTime;

    /**
     * 失效时间
     */
    @TableField(value = "end_time")
    private Date endTime;

    /**
     * 秒杀的时间段
     */
    @TableField(value = "false")
    private String SeckillPeriod;
    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private Date updateTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;



    public void setSeckillPeriod(){
        SimpleDateFormat format1 = new SimpleDateFormat("MM月dd日 HH:mm");
        String format = format1.format(this.beginTime);
        SimpleDateFormat format2 = new SimpleDateFormat("HH:mm");
        format+=" ~ "+ format2.format(this.getEndTime());
        this.setSeckillPeriod(format);
    }
}